<template>
  <div class="mod-menu">
    <el-form :inline="true">
    </el-form>

    <el-table
      :data="dataList"
      row-key="menuId"
      border
      style="width: 100%; ">
      <el-table-column
        prop="orderId"
        align="center"
        header-align="center"
        label="ID" >
      </el-table-column>
      <el-table-column
        prop="orderAllPrice"
        header-align="center"
        align="center"
        label="订单总价" >
      </el-table-column>
      <el-table-column
        prop="orderBargainPrice"
        header-align="center"
        align="center"
        label="优惠价格">
      </el-table-column>
      <el-table-column
        prop="orderEndPrice"
        header-align="center"
        align="center"
        label="优惠后价格">
      </el-table-column>
      <el-table-column
        prop="orderStatus"
        header-align="center"
        :formatter="findStatus"
        align="center"
        label="当前状态">
      </el-table-column>
      <el-table-column
        prop="openid"
        header-align="center"
        align="center"
        label="创建人">
      </el-table-column>
      <el-table-column
        prop="couponId"
        header-align="center"
        align="center"
        :formatter="IsCoupon"
        label="是否使用优惠券">
      </el-table-column>
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="payTime"
        header-align="center"
        align="center"
        label="付款时间">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="deleteHandle(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      searchItem: {},
      addVisible: false,
      dialogVisible: false,
      dataForm: '',
      disabled: false
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    getList () {
      this.$http({
        url: this.$http.adornUrl('/goods_order/page?page=' + this.pageIndex + '&size=' + this.pageSize),
        method: 'post',
        data: this.$http.adornData(this.searchItem)
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.dataList = []
          this.totalPage = 0
        }
      })
    },
    findStatus (row) {
      if (row.orderStatus === 1) {
        return '已付款'
      }
    },
    IsCoupon (row) {
      if (row.orderAllPrice === row.orderEndPrice) {
        return '未使用'
      } else {
        return '已使用'
      }
    },
    sizeChangeHandle (val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getList()
    },
    // 当前页
    currentChangeHandle (val) {
      this.pageIndex = val
      this.getList()
    }
  }
}
</script>

<style scoped>

</style>
